package com.becca.cake.model.voucher;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import com.becca.cake.core.exception.ServiceException;


/**
 * 抵用券订单实体
 * @copyright  尊星(上海)信息科技有限公司
 * @author Mouwanming
 * @date 2016年9月6日 上午11:15:17
 */
public class VoucherOrderModel implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3994580028569744664L;
	
	 	private Integer                 id;
	    /**抵用券编号*/
	    private String                  voucherCode;
	    /**用户ID*/
	    private Integer                 userId;
	    /**支付流水ID*/
	    private Integer                 voucherPaymentId;
	    /**订单状态(0:待付款 1:已付款 2:已发货 3:已完成)*/
	    private Byte                    orderStatus;
	    /**支付方式(0:微信 1：支付宝)*/
	    private Byte                    payWays;
	    /**支付时间*/
	    private Date                    payDate;
	    /**订单总金额*/
	    private Double                  totalAmount;
	    /**实际支付金额*/
	    private Double                  payAmount;
	    /**抵用券数量*/
	    private Integer                 voucherNumber;
	    /**收货人*/
	    private String                  consignee;
	    /**收货人电话*/
	    private String                  consignPhone;
	    /**收货人地址*/
	    private String                  consignAddress;
	    /**确认发货抵用券图片*/
	    private String                  deliveryPicture;
	    /**发票内容*/
	    private String                  invoiceContent;
	    /**备注*/
	    private String                  remark;
	    /**创建时间*/
	    private Date                    createdDate;
	    /**创建人*/
	    private String                  createdName;
	    /**修改时间*/
	    private Date                    updatedDate;
	    /**修改人*/
	    private String                  updatedName;
	    /**订单明细集合*/
	    private List<VoucherOrderDetailsModel> voucherOrderList;
	    /**订单状态多值*/
	    private String                  orderStatusIds;
	    private String                  userName;
	  
	   
	  

		

		/**订单编号为空*/
	    public static final String      ORDER_ID_NULL              = "订单编号为空";
	    /**订单中抵用券为空*/
	    public static final String      ORDER_GOODS_NULL           = "订单中商品不能为空";
	    /**收货人不能为空*/
	    public static final String      CONSIGNEE_IS_NULL          = "收货人不能为空";
	    /**收货人电话不能为空*/
	    public static final String      CONSIGNEE_PHONE_IS_NULL    = "收货人电话不能为空";
	    /**收货人地址不能为空*/
	    public static final String      CONSIGNEE_ADDRESS_IS_NULL  = "收货人地址不能为空";
	    /**支付方式不能为空*/
	    public static final String      PAY_TYPE_IS_NULL           = "支付方式不能为空";
	    /**订单来源不能为空*/
	    public static final String      ORDER_SOURCE_IS_NULL       = "订单来源不能为空";
	    /**订单状态不能为空*/
	    public static final String      ORDER_STATUS_NULL          = "订单状态为空";
	    /**订单信息不存在*/
	    public static final String      ORDER_NO_EXISTS            = "订单信息不存在";
	    /**订单状态异常*/
	    public static final String      ORDER_STARUS_EXCEPTION     = "订单状态异常";   
	    /**广告图片不能为空*/
	    public static final String      ORDER_PICPATH_NULL 		   ="广告图片不能为空";
	    /**图片上传失败*/
	    public static final String 		PICTURE_UPDLOAD_FAILED     ="图片上传失败";
	    
	    /**订单状态(0:待付款）*/
	    public static final Byte        ORDER_STATUS_WAIT_PAY      = 0;
	    /**订单状态(1:已付款）*/
	    public static final Byte        ORDER_STATUS_PAY           = 1;
	    /**订单状态(1:确认中 ）*/
	    public static final Byte        ORDER_STATUS_CONFIRM       = 1;
	    /**订单状态(2:已确认 ）*/
	    public static final Byte        ORDER_STATUS_CONFIRMED     = 2;
	    /**订单状态(4:已发货 ）*/
	    public static final Byte        ORDER_STATUS_SENDED        = 2;
	    /**订单状态(5:已完成）*/
	    public static final Byte        ORDER_STATUS_COMLETER      = 3;
	    /**支付方式(2:无)*/
	    public static final Byte        PAY_TYPE_NULL              = 2;
	    
	    
		public Integer getId() {
			return id;
		}
		public void setId(Integer id) {
			this.id = id;
		}
		public String getVoucherCode() {
			return voucherCode;
		}
		public void setVoucherCode(String voucherCode) {
			this.voucherCode = voucherCode;
		}
		public Integer getUserId() {
			return userId;
		}
		public void setUserId(Integer userId) {
			this.userId = userId;
		}
		public Integer getVoucherPaymentId() {
			return voucherPaymentId;
		}
		public void setVoucherPaymentId(Integer voucherPaymentId) {
			this.voucherPaymentId = voucherPaymentId;
		}
		public Byte getOrderStatus() {
			return orderStatus;
		}
		public void setOrderStatus(Byte orderStatus) {
			this.orderStatus = orderStatus;
		}
		public Byte getPayWays() {
			return payWays;
		}
		public void setPayWays(Byte payWays) {
			this.payWays = payWays;
		}
		public Date getPayDate() {
			return payDate;
		}
		public void setPayDate(Date payDate) {
			this.payDate = payDate;
		}
		public Double getTotalAmount() {
			return totalAmount;
		}
		public void setTotalAmount(Double totalAmount) {
			this.totalAmount = totalAmount;
		}
		public Double getPayAmount() {
			return payAmount;
		}
		public void setPayAmount(Double payAmount) {
			this.payAmount = payAmount;
		}
		public Integer getVoucherNumber() {
			return voucherNumber;
		}
		public void setVoucherNumber(Integer voucherNumber) {
			this.voucherNumber = voucherNumber;
		}
		public String getConsignee() {
			return consignee;
		}
		public void setConsignee(String consignee) {
			this.consignee = consignee;
		}
		public String getConsignPhone() {
			return consignPhone;
		}
		public void setConsignPhone(String consignPhone) {
			this.consignPhone = consignPhone;
		}
		public String getConsignAddress() {
			return consignAddress;
		}
		public void setConsignAddress(String consignAddress) {
			this.consignAddress = consignAddress;
		}
		public String getDeliveryPicture() {
			return deliveryPicture;
		}
		public void setDeliveryPicture(String deliveryPicture) {
			this.deliveryPicture = deliveryPicture;
		}
		public String getInvoiceContent() {
			return invoiceContent;
		}
		public void setInvoiceContent(String invoiceContent) {
			this.invoiceContent = invoiceContent;
		}
		public String getRemark() {
			return remark;
		}
		public void setRemark(String remark) {
			this.remark = remark;
		}
		public Date getCreatedDate() {
			return createdDate;
		}
		public void setCreatedDate(Date createdDate) {
			this.createdDate = createdDate;
		}
		public String getCreatedName() {
			return createdName;
		}
		public void setCreatedName(String createdName) {
			this.createdName = createdName;
		}
		public Date getUpdatedDate() {
			return updatedDate;
		}
		public void setUpdatedDate(Date updatedDate) {
			this.updatedDate = updatedDate;
		}
		public String getUpdatedName() {
			return updatedName;
		}
		public void setUpdatedName(String updatedName) {
			this.updatedName = updatedName;
		}
		 public List<VoucherOrderDetailsModel> getVoucherOrderList()
		{
			return voucherOrderList;
		}
		public void setVoucherOrderList(List<VoucherOrderDetailsModel> voucherOrderList)
		{
			this.voucherOrderList = voucherOrderList;
		}
		  public String getOrderStatusIds()
			{
				return orderStatusIds;
			}
			public void setOrderStatusIds(String orderStatusIds)
			{
				this.orderStatusIds = orderStatusIds;
			}
			public String getUserName()
			{
				return userName;
			}
			public void setUserName(String userName)
			{
				this.userName = userName;
			}
			
		/**
	     * 修改订单对象校验
	     */
	    public static void validUpdateOrder(VoucherOrderModel voucherOrderModel) {
	        if (voucherOrderModel.getId() == null) {
	            throw new ServiceException(VoucherOrderModel.ORDER_ID_NULL);
	        }
	        if (StringUtils.isEmpty(voucherOrderModel.getConsignAddress())) {
	            throw new ServiceException(VoucherOrderModel.CONSIGNEE_ADDRESS_IS_NULL);
	        }
	        if (StringUtils.isEmpty(voucherOrderModel.getConsignee())) {
	            throw new ServiceException(VoucherOrderModel.CONSIGNEE_IS_NULL);
	        }
	        if (StringUtils.isEmpty(voucherOrderModel.getConsignPhone())) {
	            throw new ServiceException(VoucherOrderModel.CONSIGNEE_PHONE_IS_NULL);
	        }
	      
	    }
	    
	    /**
	     * 校验订单编号
	     * @param id
	     */
	    public static void validOrderIdNull(Integer id) {
	        if (id == null) {
	            throw new ServiceException(VoucherOrderModel.ORDER_ID_NULL);
	        }
	    }
	    
	    /**
	     * 修改订单状态数据校验
	     * @param orderId
	     * @param orderStatus
	     * @param statusName
	     * @return
	     */
	    public static void validateUpdateOrderStatus(String orderIds, Byte orderStatus,
	                                                 String statusName) {
	        if (StringUtils.isEmpty(orderIds)) {
	            throw new ServiceException(VoucherOrderModel.ORDER_ID_NULL);
	        }
	        if (orderStatus == null) {
	            throw new ServiceException(VoucherOrderModel.ORDER_STATUS_NULL);
	        }

	        if (StringUtils.isEmpty(statusName)) {
	            throw new ServiceException(VoucherOrderModel.ORDER_STATUS_NULL);
	        }
	    }
	    
	    /**
	     * 热敏打印数据校验
	     * @param orderId
	     * @param printServiceName
	     */
	    public static void validatePrintThermalValidate(String orderId) {
	        if (StringUtils.isEmpty(orderId)) {
	            throw new ServiceException(VoucherOrderModel.ORDER_ID_NULL);
	        }
	    }
	    
	    public static String getDayOrderStatus() {
	        return "1,2,3,4";
	    }
	    
	    
	    /**
	     * 添加确认发货图片校验
	     * 
	     * @param voucherAdvertModel
	     * @param files
	     */
	    public static void validInsertOrderPictuer(VoucherOrderModel voucherOrderModel, MultipartFile files){
	        if(voucherOrderModel == null){
	            throw new ServiceException(VoucherOrderModel.ORDER_NO_EXISTS);
	        }
	        if(voucherOrderModel.getId() == null && files.isEmpty()){
	            throw new ServiceException(VoucherOrderModel.ORDER_PICPATH_NULL);
	        }

	    }
	    
	    @Override
	    public String toString() {
	        return "OrderDO [id=" + id + ", voucherCode=" + voucherCode + ", userId=" + userId
	               + ", voucherPaymentId=" + voucherPaymentId + ", orderStatus=" + orderStatus
	               + ", payWays=" + payWays + ", payDate=" + payDate
	               + ", totalAmount=" + totalAmount + ", payAmount="+ payAmount 
	               + ", voucherNumber=" + voucherNumber + ", consignee=" + consignee
	               + ", consignPhone=" + consignPhone + ", consignAddress=" + consignAddress
	               + ", deliveryPicture=" + deliveryPicture + ", invoiceContent=" + invoiceContent
	               + ", remark=" + remark + ", createdDate=" + createdDate + ", createdName=" + createdName
	               + ", updatedDate=" + updatedDate + ", updatedName=" + updatedName + "]";
	    }


}
